<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSysFormCustomViewTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sys_form_custom_view', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('field_id')->default(0)->comment('字段id');
            $table->string('field_name', 64)->default('')->comment('字段名称');
            $table->string('field_type', 64)->default('')->comment('字段类型');
            $table->string('title', 64)->default('')->comment('显示标题');
            $table->integer('form_id')->default(0)->comment('表单id');
            $table->integer('width')->default(0)->comment('显示列宽，单位px');
            $table->integer('uid')->default(0)->comment('用户编号 -1 为系统默认显示列');
            $table->boolean('is_system')->default(0)->comment('是否为系统默认显示列');
            $table->integer('order')->default(1)->comment('显示排序 升序');
            $table->integer('create_uid')->default(0);
            $table->integer('update_uid')->default(0);
            $table->bigInteger('created_at')->default(0);
            $table->bigInteger('updated_at')->default(0);
            $table->tinyInteger('action_type')->default(1);
            $table->index(['uid', 'order'], 'idx_uid_sort');
            
            $table->boolean('resizable')->default(1)->comment('是否可调整大小 1是 0否 默认1');
            $table->boolean('sortable')->default(0)->comment('是否可排序 1是 0否 默认0');
            $table->boolean('editable')->default(1)->comment('是否可编辑大小 1是 0否 默认1');
            $table->string('display_format', 64)->default('')->comment('显示格式');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sys_form_custom_view');
    }
}
